<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>扫码报修</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta name="viewport" content="width=device-width, user-scalable=no">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta name=”apple-mobile-web-app-status-bar-style” content=”default” />
		<meta name=”apple-mobile-web-app-status-bar-style” content=”black” />
		<meta name=”apple-mobile-web-app-status-bar-style” content=”black-translucent” />
		<meta content="telephone=no" name="format-detection">
		<meta content="email=no" name="format-detection">
		<meta name="format-detection" content="telephone=no"/>
		<link rel="stylesheet" href="${s.base}/mobile/css/weui.min.css" />
		<link rel="stylesheet" href="${s.base}/mobile/css/jquery-weui.css" />
		<link rel="stylesheet" href="${s.base}/mobile/css/wbNew.css" />
		<link href="${s.base}/mobile/css/weChat.css" rel="stylesheet" />
		<script type="text/javascript" src="${s.base}/mobile/js/fontSize.js"></script>
		<script type="text/javascript" src="${s.base}/mobile/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript" src="${s.base}/mobile/js/vue.js"></script>

	</head>
	<body>
	<input type="hidden" id="deviceId" value="${wbDevices.id}">
	<input type="hidden" id="roomId" value="${wbDevices.roomId}">

		<div class="main-content75 wb-service-bg" id="service-records">
			<div class="service-records">
				<div class="service-records-top">
					<div class="prebtn-icon" onclick="history.back()"><i class="cyfont">&#xe6d5;</i>上一页</div>
					<div class="service-records-top-btn"><i class="cyfont">&#xe601;</i></div>
					<div class="service-records-list">
						<records-list
							v-for="record in records"
							v-bind:key="record.id"
							v-bind:record="record"
						>			</records-list>
						<text-list
							v-for="txtlist in txtlists"
							v-bind:key="txtlist.id"
							v-bind:txtlist="txtlist"
						></text-list>
						<!-- 图片上传 -->


						<div class="weui-cell border20 " style="padding:0.2rem 0.25rem;border-bottom:none;">
							<div class="weui-cell__bd">
								<div class="weui-uploader">
									<div class="weui-uploader__hd">
										<p class="weui-uploader__title">图片上传：</p>
									</div>
									<ul class="weui-uploader__files" id="showCLJG" data-objectId="">

									</ul>
									<div class="weui-uploader__input-box pic-add" style="margin-top: 0.12rem;">
										<input id="fileCLJG"  name="file" onchange="cytImgUpload('fileCLJG','work/wb/repair','showCLJG','${token}')"  class="weui-uploader__input" type="file" accept="image/*" multiple>
									</div>
						          </div>
						        </div>
						      </div>
					</div>
						<!-- 图片上传结束 -->
						<div id="submit" class="foot-menu-btn mart20 marb40">确认结果</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script src="${s.base}/mobile/js/jquery-weui.js"></script>
	<script type="text/javascript" src="${s.base}/mobile/js/common.js"></script>
	<script type="text/javascript" src="${s.base}/mobile/js/ajaxfileupload.js"></script>
	 <script>
		Vue.component('text-list', {
		  props: ['txtlist'],
		  template: `
		    <div class="div-line-textarea border20">
		    	<label>{{txtlist.title}}</label>
		    	<textarea :id="txtlist.id" :placeholder="txtlist.placeholder">{{txtlist.content}}</textarea>
		    </div>
		  `
		})
		Vue.component('records-list', {
		  props: ['record'],
		  template: `<div class="div-line-input" >
		    	<label>{{record.title}}</label>
		    	<input :id="record.id" v-if="record.read" readonly type="text" :placeholder="record.placeholder" v-bind:value="record.content"/>
		    	<input :id="record.id" v-else type="text" :placeholder="record.placeholder" v-bind:value="record.content" v-bind:class="{colorBlue: record.isActive}" />
		    </div>`
		})
		var record =new Vue({
			el:"#service-records",
			data:{
				records:[
                    {id:"deviceName",title:"设备名称：",content:"${wbDevices.name!'无'}",placeholder:"请输入设备名称",read:true},
                    {id:"deviceNum",title:"设备编号：",content:"${wbDevices.num!'无'}",placeholder:"请输入设备编号",read:true},
                    {id:"deviceModel",title:"设备型号：",content:"${wbDevices.deviceModel!'无'}",placeholder:"请输入设备型号",read:true},
                    {id:"roomName",title:"报修位置：",content:"${wbDevices.roomName!'无'}",placeholder:"请输入报修位置",read:true},
                    {id:"servicerMobile",title:"服务商电话：",content:"${wbDevices.servicerMobile!'无'}",placeholder:"请输入服务商电话",read:true},
                    {id:"name",title:"报修人：",content:"${wbUser.name!'无'}",placeholder:"请输入报修人",read:true},
                    {id:"phone",title:"联系方式：",content:"${wbUser.phone!'无'}",placeholder:"请输入联系方式",read:true},
				],
				txtlists:[
					{id:"description",title:"故障描述：",content:"",placeholder:"请输入故障描述"}
				],
			}
		})
        var token = "${token}";
        var applyId = '${applyId}';
        var servicerId='${wbDevices.servicerId}';
        // 提交绑定
        $("#submit").on("click",function () {
            var deviceId = $("#deviceId").val();
            var roomId = $("#roomId").val();
            var deviceNum = $("#deviceNum").val();
            var deviceModel = $("#deviceModel").val();
            var roomName = $("#roomName").val();
            var deviceName = $("#deviceName").val();
            if (deviceName == null || deviceName == "") {
                $.toast("请输入设备名称","text");
                return false;
            }
            var description = $("#description").val();
            if (description == null || description == "") {
                $.toast("请输入故障描述","text");
                return false;
            }
            var attaObjectId = $("#showCLJG").attr("data-objectId");//附件id
            $.fn.doPost('/phone/wb/createRepair', {servicerId:servicerId,repairType:'2',deviceId:deviceId,roomId:roomId,deviceNum:deviceNum,deviceModel:deviceModel,token:token,applyId:applyId,deviceName:deviceName,description:description,images:attaObjectId}, function (result) {
                if (result.code == 0){
                    $.alert("报修成功，我们会尽快安排人员处理！","报修提示",function () {
                        window.location.href = "/phone/wb/index?token="+token+"&applyId="+applyId;
                    });
                }else {
                    $.toast(result.msg,"text");
                }
            });
        });
	  </script>
</html>
